<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit" />
    <title>网站后台管理系统</title>
	[#include "/admin/include/admin_static.htm"]
    <link href="${path}/resources/admin/bui/css/dpl-min.css" rel="stylesheet">
    <link href="${path}/resources/admin/bui/css/bui-min.css" rel="stylesheet">
</head>
<div class="demo-content">
    <link rel="stylesheet" href="${path}/resources/admin/bui/css/layout-min.css">

    <script src="${path}/resources/admin/bui/bui-min.js" type="text/javascript"></script>
    <script type="text/javascript" src="${path}/resources/admin/js/template-web.js"></script>
    <script type="text/javascript">
        BUI.use(['bui/layout','bui/tab','bui/data','bui/tree','bui/menu'],function (Layout,Tab,Data,Tree,Menu) {
			var nav_content = "欢迎";
            var  timestamp = parseInt(new Date('${.now}').getTime());
            //服务器时间获取
            function sysTime() {
                var d = new Date(timestamp), yyyy = d.getFullYear(), MM = d.getMonth() + 1, dd = d
                        .getDate(), hh = d.getHours(), mm = d.getMinutes(), ss = d
                        .getSeconds();
                MM = MM < 10 ? "0" + MM : MM;
                dd = dd < 10 ? "0" + dd : dd;
                hh = hh < 10 ? "0" + hh : hh;
                mm = mm < 10 ? "0" + mm : mm;
                ss = ss < 10 ? "0" + ss : ss;
                $(".systime").html([ yyyy, "-", MM, "-", dd, " ", hh, ":", mm, ":", ss ].join(""));
                timestamp = timestamp + 1000;
            }

			$.ajax( {
                url:base+"/admin/menu/nav.aspx",
                type:"get",
                dataType:"json",
                async:false,
                success : function(result) {
                    nav_content =  template("te-nav", {"nav":result});

                    timestamp = parseInt(new Date('${.now}').getTime());
                   sysTime();
                    setInterval(function() {sysTime();}, 1000);
                }
            });

            var control = new Layout.Viewport({
                width:600,
                height:500,
                elCls : 'ext-border-layout',
                children : [{
                    layout : {
                        region : 'north',
                        height : 100
                    },
                    xclass : 'controller',
                    content : nav_content
                },{
                    layout : {
                        region : 'west',
                        fit : 'both', //height,width,both,none
                        title : '导航菜单',
                        collapsable : true,
                        width : 200
                    },
                    xclass : 'controller',
                    id : 'mytree',
					content:"<div id='m2'></div>"
                },{
                    xclass : 'nav-tab', //Grid
                    layout : {
                        region : 'center',
                        title : '内容',
                        fit : 'both'
                    },
                    id : 'tab'
                }],
                plugins : [Layout.Border]
            });
            control.render();

			var loaderMenu = function(id){
                $.ajax( {
                    url:base+"/admin/menu/m/"+id+".aspx",
                    type:"get",
                    dataType:"json",
                    async:false,
                    success : function(result) {

                        $("#m2").empty();

                        var sideMenu = new Menu.SideMenu({
                            render:'#m2',
                            width:200,
                            items:result
                        });

                        sideMenu.render();
                        sideMenu.on('menuclick', function(e){
                            tab.addTab({
                                title : e.item.get('text'),
                                href : e.item.get('href'),
                                id : e.item.get('id')
                            });
                        });
                    }
                });
			};
            loaderMenu(1);

            var tab = control.getChild('tab'),//通过id获取
                    tree = control.getChild('mytree',true);  //级联查找树节点

            tree.on('itemclick',function (ev) {
                var node = ev.item,
                        id = node.id,
                        text = node.text,
                        href = node.href;
                tab.addTab({
                    title : text,
                    href : href,
                    id : id
                });
            });



			$(".nav-item").click(function(){
				var id = $(this).attr("value");
                loaderMenu(id);
			});
        });

        function clearCache(borrowid){
            oDialog.confirm('确定要清除所有ehcache缓存吗？', function() {
                        ajax( {
                            type : "post",
                            url : '${path}/admin/celarCache.aspx',
                            success : function(result) {
                                oDialog.prompt(result.content, 500,500,function() {


                                });
                            }
                        });

                    }
            )};
    </script>
</div>

<script type="text/html" id="te-nav">
   <link href="${path}/resources/admin/css/haiersoft.css" rel="stylesheet" type="text/css" media="screen,print" />
    <div id="Header">
        <img src="${path}${p2p_get_global('logo')}" alt="" width="200" height="76" style="float: left; margin-left: 10px; margin-top: 10px" />
        <div class="user">
            <div>
                <p>欢迎登录，管理员</p>
                <a href="${path}/a/logout.aspx"><img src="${path}/resources/admin/images/common/ico07.gif" width="20" height="20" alt=""></a>
            </div>
            <div>
                <p>系统时间：</p>
                <p class="systime">$ <p class="systime">${.now}</p>{.now}</p>
            </div>
            <div>
                <a  onclick="clearCache()" >清除缓存</a>
            </div>
            <div>
                <p><a target="_blank" href="/"> 返回前台</a></p>
            </div>
        </div>
        <nav>
            <div id="Navi" style="">
                <ul style="margin-left: 160px;">
					{{each nav }}
                    <li class="nav0{{$value.id}}">
                        <a value="{{$value.id}}" href="javascript:void(0)"  class="nav-item" title={{$value.name}}>{{$value.name}}</a></li>
					{{/each}}
                </ul>
            </div>
        </nav>
    </div>
</script>
<body>
</body>
</html>